//
//  DCImageAndTextField.m
//  Driver
//
//  Created by 大橙子 on 2018/11/8.
//  Copyright © 2018 Tomous. All rights reserved.
//

#import "DCImageAndTextField.h"

@implementation DCImageAndTextField
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setUpUI];
    }
    return self;
}
-(void)setUpUI
{
    UIImageView *imageView = [[UIImageView alloc]init];
    //    imageView.backgroundColor = [UIColor redColor];
    self.imageView = imageView;
    [self addSubview:imageView];
    
    UITextField *textField = [[UITextField alloc]init];
    //    textLabel.backgroundColor = [UIColor yellowColor];
    textField.clearButtonMode = UITextFieldViewModeWhileEditing;
    self.textField = textField;
    [self addSubview:self.textField];
    
    self.line = [[UIView alloc]init];
    self.line.backgroundColor = [UIColor lightGrayColor];
    self.line.alpha = 0.6;
    [self addSubview:self.line];
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat kMargin = 15;
    self.imageView.height = self.height - kMargin;
    self.imageView.width = self.imageView.height;
    self.imageView.x = 0;
    self.imageView.y = kMargin/2;
    
    self.textField.frame = CGRectMake(self.imageView.right+3, 0, self.width - self.imageView.width, self.height);
    self.line.frame = CGRectMake(self.textField.x, self.textField.bottom, self.textField.width, 0.5);
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
